package com.yoki.loginview;

import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.yoki.loginview.Save.SaveString;
import com.yoki.loginview.db.AccountDBHelper;

public class UserncActivity extends AppCompatActivity {

    TextView UserText;
    EditText UserTB;
    Button ChangeBtn;
    AccountDBHelper helper;
    Cursor cursor;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_usernc);
        UserText = findViewById(R.id.UserText);
        UserTB = findViewById(R.id.CUserTB);
        ChangeBtn = findViewById(R.id.ChangeBtn);
        helper = new AccountDBHelper(UserncActivity.this,AccountDBHelper.VERSION_1);
        cursor = helper.select(null,null);
        cursor.move(SaveString.User+1);
        UserText.setText(cursor.getString(5));
        ChangeBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                helper.update(cursor.getString(0),UserTB.getText().toString());
                Toast.makeText(UserncActivity.this,"修改成功",Toast.LENGTH_SHORT).show();
                finish();
            }
        });
    }
}
